let express = require(`express`); //引入express
let Mock = require(`mockjs`); //引入mock
var router = express.Router();
var Random = Mock.Random;
let app = express(); //实例化express
app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  next();
});//服务端响应代码片段/routes/operationboard.js:
//业务逻辑为查询系统告警信息列表
//node服务器启动后，请求地址为:127.0.0.1:3000/operationboard/systemwarn
//3000端口为express默认启动端口



router.get('/systemwarn', function (req, res, next) {
  var data =Mock.mock({
    'list|20':[{
      'id|+1':1,
      'serial_number|1-100':1,
      'warn_number|1-100':1,
      'warn_name|1':['流水线编排服务异常','磁盘占用超过阈值'],
      'warn_level|1':['紧急','重要'],
      'warn_detail':'环境IP:10.114.123.12,服务名称:XX',
      'create_time':Random.datetime(),
      'finish_time':Random.datetime(),
      'contact|4':'abc'
    }]
  });

  res.send({
    meta : {
      message: 'success'
    },
    status:true,
    data: data.list
  })
})
module.exports = router;
